﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.Hr.Entity;
namespace Chenxin.Lib.Hr.BLL
{
    /// <summary>
    /// 业务逻辑类WorkReport_OutBox 的摘要说明。
    /// </summary>
    public class WorkReport_OutBox
    {
        public WorkReport_OutBox()
        { }
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public static bool Exists(Guid RecordId)
        {
            return Chenxin.Lib.Hr.DAL.WorkReport_OutBox.Exists(RecordId);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static void Add(Chenxin.Lib.Hr.Entity.WorkReport_OutBox model)
        {
            Chenxin.Lib.Hr.DAL.WorkReport_OutBox.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static void Update(Chenxin.Lib.Hr.Entity.WorkReport_OutBox model)
        {
            Chenxin.Lib.Hr.DAL.WorkReport_OutBox.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public static void Delete(Guid RecordId)
        {

            Chenxin.Lib.Hr.DAL.WorkReport_OutBox.Delete(RecordId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Chenxin.Lib.Hr.Entity.WorkReport_OutBox GetModel(Guid RecordId)
        {

            return Chenxin.Lib.Hr.DAL.WorkReport_OutBox.GetModel(RecordId);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Hr.DAL.WorkReport_OutBox.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static List<Chenxin.Lib.Hr.Entity.WorkReport_OutBox> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Hr.DAL.WorkReport_OutBox.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static List<Chenxin.Lib.Hr.Entity.WorkReport_OutBox> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Hr.Entity.WorkReport_OutBox> modelList = new List<Chenxin.Lib.Hr.Entity.WorkReport_OutBox>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Hr.Entity.WorkReport_OutBox model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Hr.Entity.WorkReport_OutBox();
                    if (dt.Rows[n]["RecordId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["RecordId"].ToString());
                    }
                    if (dt.Rows[n]["SenderId"].ToString() != "")
                    {
                        model.SenderId = new Guid(dt.Rows[n]["SenderId"].ToString());
                    }
                    if (dt.Rows[n]["SendTime"].ToString() != "")
                    {
                        model.SendTime = DateTime.Parse(dt.Rows[n]["SendTime"].ToString());
                    }
                    model.Subject = dt.Rows[n]["Subject"].ToString();
                    model.Content = dt.Rows[n]["Content"].ToString();
                    if (dt.Rows[n]["SenderDepartId"].ToString() != "")
                    {
                        model.SenderDepartId = new Guid(dt.Rows[n]["SenderDepartId"].ToString());
                    }
                    model.SenderDepartName = dt.Rows[n]["SenderDepartName"].ToString();
                    if (dt.Rows[n]["SenderCompanyId"].ToString() != "")
                    {
                        model.SenderCompanyId = new Guid(dt.Rows[n]["SenderCompanyId"].ToString());
                    }
                    model.SenderCompanyName = dt.Rows[n]["SenderCompanyName"].ToString();
                    if (dt.Rows[n]["SenderCityId"].ToString() != "")
                    {
                        model.SenderCityId = new Guid(dt.Rows[n]["SenderCityId"].ToString());
                    }
                    model.SenderCityName = dt.Rows[n]["SenderCityName"].ToString();
                    model.ReceiverId = dt.Rows[n]["ReceiverId"].ToString();
                    model.ReceiverName = dt.Rows[n]["ReceiverName"].ToString();
                    if (dt.Rows[n]["isDeleted"].ToString() != "")
                    {
                        if ((dt.Rows[n]["isDeleted"].ToString() == "1") || (dt.Rows[n]["isDeleted"].ToString().ToLower() == "true"))
                        {
                            model.isDeleted = true;
                        }
                        else
                        {
                            model.isDeleted = false;
                        }
                    }
                    if (dt.Rows[n]["ParentId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["ParentId"].ToString());
                    }
                    if (dt.Rows[n]["RootId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["RootId"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}

